package org.imis.util;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class HibernateUtil {
	private static SessionFactory sessionFactory;
	private static Session sess;
	static{
		ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");   
        sessionFactory = (SessionFactory) ac.getBean("sessionFactory");  
        sess= sessionFactory.openSession();
	}
	public static Session currentSession()
	{
		
        return sess;
	}
	
	public static  void closeSession()
	{
		sess.close();
        sessionFactory.close();
	}

}
